/*
ID: quxiao82
LANG: C++
PROG: nuggets
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAX = 1<<16 + 1;
const int N = 10;

int n;
int box[N];
short int canMake[MAX];

void Input ()
{
     scanf("%d", &n);
     int i;
     for (i = 0; i < n; i ++)
          scanf("%d", &box[i]);
}

int gcd (int x, int y)
{
     while( x != y )
     {
          if( x > y)
               x -= y;
          else
               y -= x;
     }
     return x;
}

void Solve ()
{
     int i, j, bound, gcdNum;

     gcdNum = box[0];
     for (i = 1; i < n; i ++)
          gcdNum = gcd(gcdNum, box[i]);
     if ( gcdNum != 1 )
     {
          printf("0\n");
          return;
     }

     canMake[0] = 1;
     sort(box, box+n);
     bound = box[n-1] * box[n-1];
     for (i = 0; i < bound; i ++)
     {
          if ( ! canMake[i] )
               continue;
          for (j = 0; j < n; j ++)
          {
               if ( i + box[j] < bound )
                    canMake[i+box[j]] = 1;
          }
     }

     for (i = bound-1; i >= 0; i --)
     {
          if ( !canMake[i] )
          {
               printf("%d\n", i);
               return;
          }
     }
     printf("0\n");
}

int main ()
{
     freopen( "nuggets.in", "r" , stdin );
     freopen( "nuggets.out", "w" , stdout );

     Input ();
     Solve ();

     return 0;
}